<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Atp</title>
    <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
    <script type="text/javascript" src="js/ext-base.js"></script>
    <script type="text/javascript" src="js/ext-all.js"></script>
</head>
<body>
     <script type="text/javascript">
		var bindIframe = function(s,scroll){
			return '<div style="width:100%;height:100%;"><iframe src="'+s+'" style="width:100%;height:100%;" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="'+(scroll?'yes':'no')+'" allowtransparency="yes"></iframe></div>';
		}
		
		// 左边功能树
		var menuTree = new Ext.tree.TreePanel({
		region : 'west',
		title : '功能菜单',
		width : 180,
		minSize : 150,
		maxSize : 200,
		split : true,
		autoScroll : true,
		autoHeight : false,
		collapsible : true,
		rootVisable : false,// 不显示根节点
		root : new Ext.tree.TreeNode({
		   id : 'root',
		   text : '功能菜单',
		   draggable : false,
		   expanded : true
		})
		});

		//添加根节点
        var addChildTreeNode = function(id,title,src,scroll){
        	menuTree.root.appendChild(new Ext.tree.TreeNode({
        		id :id,
        		text :title+'<b id="'+id+'_count" style="color:red;"></b>',
        		listeners : {
        		   'click' : function(node, event) {
        			event.stopEvent();
        			var n = contentPanel.getComponent(node.id);
        			if (!n) {
        			 // 判断是否已经打开该面板
        			 n = contentPanel.add({
        			  'id' : node.id,
        			  'title' : node.text,
        			  closable : true,
        			  html :bindIframe(src,scroll) 
        			 });
        			}
        			contentPanel.setActiveTab(n);
        		   }
        		}
        		}));
        }

        addChildTreeNode('deparManager','部门管理','deparManager.html',false);
        addChildTreeNode('proManager','工作组管理','proManager.html',false);
        addChildTreeNode('staffManager','人员管理','staffManager.html',false);
        addChildTreeNode('commManager','重要信息','commManager.html',false);
        addChildTreeNode('reportManager','我来找茬','reportManager.html',false);
        addChildTreeNode('jobReportManager','工作汇报','jobReportManager.html',false);
        addChildTreeNode('weatherManager','天气预报','weatherManager.html',false);
        addChildTreeNode('consultManager','观众意见','consultManager.html',false);
        addChildTreeNode('userStatus','PUSH STATUS','http://124.74.67.130:7070/user.do',true);
        addChildTreeNode('version','上传新版本','version/upload.jsp',false);
        addChildTreeNode('group','PhoneHomeAppGroups','groupManager.html',false);
        addChildTreeNode('apps','PhoneHomeGroupApps','appsManager.html',false);
        
		// 右边具体功能面板区
		var contentPanel = new Ext.TabPanel({
		region : 'center',
		enableTabScroll : true,
		activeTab : 0,
		items : [{
		   id : 'homePage',
		   title : '首页',
		   autoScroll : false,
		   html : bindIframe('welcome.html')
		}]
		});


		Ext.onReady(function() {
		new Ext.Viewport({
		   layout : 'border',
		   items : [{
			region : "north",
			height : 50,
			html : '<div style="width:100%;height:100%;background-color:black;"><img src="imgs/data_title_bg.jpg"/></div>'
		   },
		   menuTree, contentPanel, 
		   {
			region : "south",
			height : 50,
			html : '<div style="width:100%;height:100%;background-color:black;"><img src="imgs/footer_bg.jpg"/></div>'
		   }]
		});


		function updateReportCount(){
			Ext.Ajax.request({
	     		url: 'polling/loadSerInfo.action?mobileID=a00000220a04a8&params=select%20concat%28%27%28%27,count%28*%29,%27%29%27%29%20from%20yw_command%20c%20where%20c.status=%270%27%20and%20c.commType=%272%27 ',
	     	 	success: function(response, options) {
	   			var mData = Ext.util.JSON.decode(response.responseText);                                             
	     			if(mData&&mData.res&&mData.res.length==1){
	     				document.getElementById("reportManager_count").innerHTML = mData.res[0];
	     			}else{
	     				document.getElementById("reportManager_count").innerHTML = "";
		     		}
	     		},
	            failure:function(response,options){
	            }
	 	 });
			window.setTimeout(updateReportCount,30000);
		}

		updateReportCount();

		function updateCommandCount(){
			Ext.Ajax.request({
	     		url: 'polling/loadSerInfo.action?mobileID=a00000220a04a8&params=select%20concat%28%27%28%27,count%28*%29,%27%29%27%29%20from%20yw_command%20c%20where%20c.replyStatus%20is%20null%20and%20c.status=%270%27%20and%20c.commType=%271%27',
	     	 	success: function(response, options) {
	   			var mData = Ext.util.JSON.decode(response.responseText);                                             
	     			if(mData&&mData.res&&mData.res.length==1){
	     				document.getElementById("commManager_count").innerHTML = mData.res[0];
	     			}else{
	     				document.getElementById("commManager_count").innerHTML = "";
		     		}
	     		},
	            failure:function(response,options){
	            }
	 	 });
			window.setTimeout(updateCommandCount,30000);
		}

		updateCommandCount();

		function updateJobReportCount(){
			Ext.Ajax.request({
	     		url: 'polling/loadSerInfo.action?mobileID=a00000220a04a8&params=select%20concat%28%27%28%27,count%28*%29,%27%29%27%29%20from%20yw_command%20c%20where%20c.replyStatus%20is%20null%20and%20c.status=%270%27%20and%20c.commType=%273%27',
	     	 	success: function(response, options) {
	   			var mData = Ext.util.JSON.decode(response.responseText);                                             
	     			if(mData&&mData.res&&mData.res.length==1){
	     				document.getElementById("jobReportManager_count").innerHTML = mData.res[0];
	     			}else{
	     				document.getElementById("jobReportManager_count").innerHTML = "";
		     		}
	     		},
	            failure:function(response,options){
	            }
	 	 });
			window.setTimeout(updateJobReportCount,30000);
		}

		updateJobReportCount();
		});
	 </script>
</body>
</html>
